package com.sz.app.edi.rest.edi.token;

import com.sz.app.edi.base.dto.AccessToken;
import com.sz.app.edi.base.service.SynCompanyAccountService;
import com.sz.app.edi.rest.edi.base.Response;
import com.sz.biz.app.web.BaseController;
import com.sz.common.base.dto.ResultDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * Function: edi token管理
 * Author: hpeng.wang.<br>
 * Date: 2017-06-23 16:08:00.
 */
@RestController
@RequestMapping("${out}")
@Api(description = " ", tags = "050-000、EDI-获取token")
public class EdiSynCompanyController extends BaseController {
    @Autowired
    private SynCompanyAccountService synCompanyAccountService;

    /**
     * 获取token
     */
    @ApiOperation(value = "获取token", notes = "获取token")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "apiKey", value = "apiKey", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "securityKey", value = "securityKey", required = true, dataType = "string", paramType = "query")})
    @RequestMapping(value = "/token", method = {RequestMethod.GET})
    public Response save(@RequestParam String apiKey, @RequestParam String securityKey) {
        AccessToken accessToken = synCompanyAccountService.generateToken(apiKey, securityKey);
        //返回信息
        Response result = new Response();
        result.setData(accessToken);
        return result;
    }


}
